The System.Threading Namespace

Under the .NET platform, the System.Threading namespace provides a number of types that enable the direct construction of multithreaded applications. In addition to providing types that allow you to interact with a particular CLR thread, this namespace defines types that allow access to the CLR maintained thread pool, a simple (non–GUI-based) Timer class, and numerous types used to provide synchronized access to shared resources. Table 19-1 lists some of the core members of this namespace. (Be sure to consult the .NET Framework 4.0 SDK documentation for full details.)

Table 19-1. Select Types of the System.Threading Namespace

Type Meaning in Life
Interlocked This type provides atomic operations for variables that are shared by multiple threads.
Monitor This type provides the synchronization of threading objects using locks and wait/signals. The C# lock keyword makes use of a Monitor object under the hood.
Mutex This synchronization primitive can be used for synchronization between application domain boundaries.
ParameterizedThreadStart This delegate allows a thread to call methods that take any number of arguments.
Semaphore This type allows you to limit the number of threads that can access a resource, or a particular type of resource, concurrently.
Thread This type represents a thread that executes within the CLR. Using this type, you are able to spawn additional threads in the originating AppDomain.
ThreadPool This type allows you to interact with the CLR-maintained thread pool within a given process.
ThreadPriority This enum represents a thread’s priority level (Highest, Normal, etc.).
ThreadStart This delegate is used to specify the method to call for a given thread. Unlike the ParameterizedThreadStart delegate, targets of ThreadStart must always have the same prototype.
ThreadState This enum specifies the valid states a thread may take (Running, Aborted, etc.).
Timer This type provides a mechanism for executing a method at specified intervals.
TimerCallback This delegate type is used in conjunction with Timer types.